;
define(function (required, exports, modules) {
    var modal = require('mods/modal')

    exports.notice_editor = function () {
        $('.notice-save').click(function () {
            if ($(this).hasClass('disabled')) {
                modal.alert('系统正在处理中,请不要重复请求~~~');
                return false
            }

            var notice_title = $('input[name=notice-title]').val()
            var notice_content = $("#notice_editor").val()
            var notice_id = $('input[name=notice-id]').val()
            var _csrf = $('#csrf').val()

            if (notice_title.length < 1) {
                modal.msg('请填写公告标题')
                return false
            }

            if (notice_content.length < 1) {
                modal.msg('请填写公告内容')
                return false
            }

            $(this).addClass('disabled')

            $.ajax({
                url: '/admin/notice/set',
                type: 'POST',
                dataType: 'json',
                data: {
                    notice_title: notice_title,
                    notice_content: notice_content,
                    notice_id: notice_id,
                    _csrf: _csrf,
                },
                success: function (res) {
                    $(this).removeClass('disabled');
                    if (res.code == 200) {
                        modal.msg(res.msg, {}, function () {
                            window.location.href = '/admin/notice/index'
                        })
                    } else {
                        modal.alert(res.msg)
                        return false
                    }
                }
            })
        });
    }
})